import { ref, onMounted, onUnmounted } from 'vue'
import { onPageScroll } from '@dcloudio/uni-app'

export function useCommon(threshold = 30) {
  const bgColor = ref('transparent')
  
  const handleScroll = ({scrollTop}) => {
   
    bgColor.value = scrollTop > threshold ? '#ffffff' : 'transparent'
  }

  onMounted(() => {
    onPageScroll(handleScroll)
  })

  onUnmounted(() => {
  
  })

  return { bgColor }
}